﻿@using HCQ2_Model
@{
    ViewBag.Title = "素材编辑界面";
}
@section headerSection{
    <link href="~/Resources/mainFrame/js/plugins/zTree3/css/metroStyle/metroStyle.css" rel="stylesheet" />
    <script src="~/Resources/mainFrame/js/plugins/zTree3/js/jquery.ztree.core.min.js"></script>
    <script src="~/Resources/mainFrame/js/plugins/zTree3/js/jquery.ztree.excheck.min.js"></script>
    <script src="~/Resources/mainFrame/js/plugins/zTree3/js/jquery.ztree.exedit.min.js"></script>
    <script src="~/Resources/tools/search_zTree.js"></script>
    <style>
        #unitTree {
            width: 400px;
            height: 300px;
            padding: 0;
            border: 1px solid #E7EAEC;
            background-color: #FFFFFF;
            position: fixed;
            z-index: 9;
            overflow: auto;
            display: none;
        }
    </style>
}
<div id="entryHtml" class="wrapper animated fadeInRight autoHeight">
    <!-- Panel Other -->
    <div class="row autoHeight" style="background-color: #fff;">
        <div class="col-sm-12 col-sm-leftRight">
            <form class="form-horizontal m-t" id="orgFormTable" method="post" style="margin-bottom:120px;">
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">@ViewBag.pageName 标题<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <input id="file_name" name="file_name" type="text" required="" aria-required="true" class="form-control input-sm" placeholder="请输入标题" title="请输入标题" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">浏览次数：</label>
                    <div class="col-sm-7">
                        <input id="browse_num" name="browse_num" type="text" value="0" class="form-control input-sm" placeholder="浏览次数" title="浏览次数" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">别名：</label>
                    <div class="col-sm-7">
                        <textarea class="form-control" id="alias_name" name="alias_name" rows="2" placeholder="请输入别名" title="请输入别名"></textarea>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">点赞次数：</label>
                    <div class="col-sm-7">
                        <input id="vr_star" name="vr_star" type="text" class="form-control input-sm" value="0" placeholder="点赞次数" title="点赞次数" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">简介：</label>
                    <div class="col-sm-7">
                        <textarea class="form-control" id="file_note" name="file_note" rows="2" placeholder="请输入简介" title="请输入简介"></textarea>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">下载次数：</label>
                    <div class="col-sm-7">
                        <input id="down_number" name="down_number" type="text" value="0" class="form-control input-sm" placeholder="下载次数" title="下载次数" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">推荐<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="isRecommend" name="isRecommend" title="请选择推荐状态" data-live-search="true" class="form-control input-sm selectpicker" placeholder="请选择推荐状态" required="" aria-required="true">
                            <option value="0" selected>不推荐</option>
                            <option value="1">推荐</option>
                        </select>
                        <input type="hidden" id="is_recommend" name="is_recommend" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">评论次数：</label>
                    <div class="col-sm-7">
                        <input id="talk_num" name="talk_num" type="text" value="0" class="form-control input-sm" placeholder="评论次数" title="评论次数" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">权限：</label>
                    <div class="col-sm-7">
                        <select id="folder_limit" name="folder_limit" title="请选择权限" class="form-control input-sm selectpicker" placeholder="请选择权限" style="padding: 5px 10px;" required="" aria-required="true">
                            <option value="" selected>空</option>
                        </select>
                    </div>
                </div>
                <div id="QD_fileStatus" class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">属性<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="fileStatus" name="fileStatus" title="请选择属性" class="form-control input-sm selectpicker" placeholder="请选择属性" disabled="disabled">
                            <option value="0">私有</option>
                            <option value="1">公开</option>
                            <option value="2">重新审核</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">编辑：</label>
                    <div class="col-sm-7">
                        <select id="allowEdit" name="allowEdit" data-live-search="true" title="请选择编辑权限" class="form-control input-sm selectpicker" placeholder="请选择编辑权限" style="padding: 5px 10px;">
                            <option value="0">不可编辑</option>
                            <option value="1" selected>允许编辑</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">审核通过时间：</label>
                    <div class="col-sm-7">
                        <input id="approve_time" name="approve_time" disabled="disabled" type="text" class="form-control input-sm" placeholder="审核通过时间" title="审核通过时间" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">素材格式<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="mater_type" name="mater_type" title="请选择素材格式" data-live-search="true" class="form-control input-sm selectpicker" placeholder="请选择素材格式" required="" aria-required="true">
                            <option value="" selected>空</option>
                        </select>
                        <input type="hidden" id="pro_form" name="pro_form" value="" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">审核人：</label>
                    <div class="col-sm-7">
                        <input id="approve_name" name="approve_name" disabled="disabled" type="text" class="form-control input-sm" placeholder="审核人" title="审核人" />
                    </div>
                </div>
                <div id="QD_pro_type" class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">产品类别<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="pro_type" name="pro_type" title="请选择产品类别" class="form-control input-sm selectpicker" required="" aria-required="true" placeholder="请选择产品类别">
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">最后修改时间：</label>
                    <div class="col-sm-7">
                        <input id="update_time" name="update_time" disabled="disabled" type="text" class="form-control input-sm" placeholder="最后修改时间" title="最后修改时间" />
                    </div>
                </div>
                <div id="QD_file_classify" class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">@ViewBag.pageName 适合分类<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="file_classify" name="file_classify" title="请选择适合分类" class="form-control input-sm selectpicker" data-live-search="true" required="" aria-required="true" placeholder="请选择适合分类"></select>
                        <!-- 素材类型 -->
                        <input type="hidden" id="file_id" name="file_id" value="" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">最后修改人：</label>
                    <div class="col-sm-7">
                        <input id="update_name" name="update_name" disabled="disabled" type="text" class="form-control input-sm" placeholder="最后修改人" title="最后修改人" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">目录导航<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <input id="folder_name" name="folder_name" type="text" required="" aria-required="true" class="form-control input-sm" placeholder="请选择目录导航" title="请选择目录导航" />
                        <div id="unitTree" class="col-sm-7"></div>
                        <input id="folder_id" name="folder_id" type="hidden" />
                        <input id="folder_path" name="folder_path" type="hidden" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">上传时间：</label>
                    <div class="col-sm-7">
                        <input id="create_time" name="create_time" disabled="disabled" type="text" class="form-control input-sm" placeholder="上传时间" title="上传时间" />
                    </div>
                </div>
                <div id="QD_unit_code" class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">所属单位：</label>
                    <div class="col-sm-7">
                        <select id="unit_code" name="unit_code" title="请选择所属单位" class="form-control input-sm selectpicker" placeholder="请选择所属单位" style="padding: 5px 10px;">
                            <option value="">空</option>
                        </select>
                        <input type="hidden" id="org_unit" name="org_unit" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">作者：</label>
                    <div class="col-sm-7">
                        <input id="folder_author" name="folder_author" disabled="disabled" type="text" class="form-control input-sm" placeholder="编号" title="编号" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">序号：</label>
                    <div class="col-sm-7">
                        <input id="file_order" name="file_order" onblur="help.int('file_order')" type="text" class="form-control input-sm" placeholder="请输入节点序号" title="请输入节点序号" />
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">代码<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <input id="folder_num" name="folder_num" type="hidden" class="form-control input-sm" placeholder="代码" title="代码" />
                        <input id="file_code" name="file_code" type="text" class="form-control input-sm" placeholder="代码" title="代码" />
                    </div>
                </div>
                <div id="QD_file_status" class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">状态<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="file_status" name="file_status" title="请选择状态" data-live-search="true" class="form-control input-sm selectpicker" disabled="disabled" placeholder="请选择状态" required="" aria-required="true">
                            <option value="0">私有</option>
                            <option value="1">待审核</option>
                            <option value="3">免费共享</option>
                            <option value="4">下架</option>
                            <option value="5">已上架</option>
                            <option value="6">审核未通过</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">价格：</label>
                    <div class="col-sm-7">
                        <input id="file_money" name="file_money" disabled="disabled" type="text" class="form-control input-sm" placeholder="价格" title="价格" />
                    </div>
                </div>
                <div id="QD_supplyType" class="form-group col-sm-6">
                    <label class="col-sm-5 control-label">商品来源<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                    <div class="col-sm-7">
                        <select id="supplyType" name="supplyType" title="请选择商品来源" data-live-search="true" class="form-control input-sm selectpicker" placeholder="请选择商品来源" required="" aria-required="true">
                            <option value="0" selected>个人</option>
                            <option value="1">自营</option>
                        </select>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                @{
                    List<T_VRGoodDisiPrice> priceList = (List<T_VRGoodDisiPrice>)ViewBag.goodPrice;
                    string materType = ViewBag.materType;
                    int goodStatus = ViewBag.goodStatus;
                    if (materType.Equals("QDMaterial"))
                    {
                        //元宇宙素材价格
                        <div class="form-group col-sm-12">
                            <div class="col-sm-3" style="width:20.5%;text-align:right;">
                                <div style="width: 150px; display: inline-block;">
                                    <select id="file_title" name="file_title" title="请选择价格" data-live-search="true" class="form-control input-sm selectpicker" placeholder="请选择价格" required="" aria-required="true">
                                        <option value="0" selected>无期限</option>
                                        <option value="1">一个月</option>
                                        <option value="6">六个月</option>
                                        <option value="12">一年</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-3" style="width:28.5%;">
                                <input id="file_price" name="file_price" type="text" class="form-control input-sm filePrice" required="" aria-required="true" placeholder="请输入金额" title="请输入金额" />
                            </div>
                        </div>
                    }
                    else
                    {
                        //其他素材
                        if (priceList.Count > 0)
                        {
                            for (int i = 0; i < priceList.Count; i += 2)
                            {
                                int j = i;
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-3 control-label" style="width:20.5%;">@priceList[j].op_month 个月金额<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                                    <div class="col-sm-3" style="width:28.5%;">
                                        <input id="file_price" name="file_price" type="text" op_month="@priceList[j].op_month" class="form-control input-sm filePrice" placeholder=@priceList[j].op_month" 个月金额" title=@priceList[j].op_month" 个月金额" required="" aria-required="true" value="@priceList[j].ori_price" />
                                    </div>
                                    @{
                                        j++;
                                        if (priceList.Count > j)
                                        {
                                            <label class="col-sm-2 control-label" style="width:20.5%;">@priceList[j].op_month 个月金额<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                                            <div class="col-sm-3" style="width:28.5%;">
                                                <input id="file_price" name="file_price" type="text" op_month="@priceList[j].op_month" class="form-control input-sm filePrice" placeholder=@priceList[j].op_month" 个月金额" title=@priceList[j].op_month" 个月金额" required="" aria-required="true" value="@priceList[j].ori_price" />
                                            </div>
                                        }
                                    }
                                </div>
                            }
                        }
                        else
                        {
                            <div class="form-group col-sm-12">
                                <label class="col-sm-3 control-label" style="width:20.5%;">1个月金额<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                                <div class="col-sm-3" style="width:28.5%;">
                                    <input id="file_price" name="file_price" type="text" op_month="1" class="form-control input-sm filePrice" required="" aria-required="true" placeholder="请输入1个月金额" title="请输入1个月金额" />
                                </div>
                                <label class="col-sm-2 control-label" style="width:20.5%;">3个月金额<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                                <div class="col-sm-3" style="width:28.5%;">
                                    <input id="file_price" name="file_price" type="text" op_month="3" class="form-control input-sm filePrice" required="" aria-required="true" placeholder="请输入3个月金额" title="请输入3个月金额" />
                                </div>
                            </div>
                            <div class="form-group col-sm-12">
                                <label class="col-sm-3 control-label" style="width:20.5%;">6个月金额<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                                <div class="col-sm-3" style="width:28.5%;">
                                    <input id="file_price" name="file_price" type="text" op_month="6" class="form-control input-sm filePrice" required="" aria-required="true" placeholder="请输入6个月金额" title="请输入6个月金额" />
                                </div>
                                <label class="col-sm-2 control-label" style="width:20.5%;">12个月金额<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                                <div class="col-sm-3" style="width:28.5%;">
                                    <input id="file_price" name="file_price" type="text" op_month="12" class="form-control input-sm filePrice" required="" aria-required="true" placeholder="请输入12个月金额" title="请输入12个月金额" />
                                </div>
                            </div>
                        }
                    }
                }
            </form>
        </div>
    </div>
</div>
@section footSection{
    <script>
        var materType = "@ViewBag.materType";
        var priceTitle = "@ViewBag.priceTitle",
            priceMoney = "@ViewBag.priceMoney";
        var fileId, isread, isFolder = false, doc_type, pageType, pro_type, operator;
        var entryType = $.getUrls("entryType"), $file_status, folder_id, folder_path;
        var unitzTree;
        var entryManager = {
            initPage: function () {
                showLoadBoxs();
                if (!entryManager.initData())
                    return false;
                entryManager.bindZtree();
                entryManager.initSelect();
                entryManager.initForm();
                entryManager.bindEvent();
                delLoadBoxs();
            },
            initData: function () {
                fileId = $.getUrls("file_id");
                isread = $.getUrls("read");
                pageType = $.getUrls("pageType");
                doc_type = $.getUrls("doc_type");
                pro_type = $.getUrls("pro_type");
                operator = $.getUrls("operator");//操作类别：add/edit，默认edit
                folder_id = $.getUrls("folder_id");
                folder_path = $.getUrls("folder_path");
                folder_name = $.getUrls("folder_name");
                if (!operator)
                    operator = "edit";
                if (!doc_type)
                    doc_type = 3;
                if (!fileId && operator === "edit") {
                    layer.msg("ID Error！");
                    return false;
                }
                if (folder_name)
                    $('#folder_name').val(decodeURI(folder_name));
                if (folder_id)
                    $('#folder_id').val(folder_id);
                if (folder_path)
                    $('#folder_path').val(folder_path);
                if (!pageType)
                    pageType = "";
                //待审核时去掉所属项目
                if (doc_type === 5)
                    pageType = "";
                return true;
            },
            initSelect: function () {
                //产品类别
                $('#pro_type').initSelectcontrol("vrProType");
                $('#file_classify').initSelectcontrol("docClassify");
                $('#folder_limit').initSelectcontrol("docLimits",true);//权限
                $('#mater_type').initSelectcontrol("docMaterType",true);//素材格式
                $.ajax({
                    url: ctx + '/SysCommon/GetDictionaryByCode',
                    type: "post",
                    cache: false,
                    async: false,
                    data: { fieldCode: 'SysUserUnit' },
                    dataType: 'json',
                    success: function (data) {
                        if (data.Statu === 1) {
                            layer.msg(data.Msg, { icon: 5 });
                            return false;
                        }
                        var itemStr = "";
                        $.each(data.Data, function (i, item) {
                            itemStr += "<option value='" + item.code_value + "'>" + item.code_name + "</option>";
                        });
                        $('#org_unit').append(itemStr);
                        $('.selectpicker').selectpicker({ size: 6 });
                        $('.selectpicker').selectpicker('refresh');
                    },
                    error: function () {
                        layer.msg('数据异常~', { icon: 5 });
                    }
                });
                //初始化状态
                if (entryType && entryType === "approve") {
                    var fileStatus = "<option value='5' selected=''>通过</option><option value='6'>不通过</option>";
                    $("#file_status").removeAttr("disabled");//开启状态
                    $("#file_status").empty();
                    $('#file_status').selectpicker('refresh');
                    $('#file_status').append(fileStatus);
                    $('#file_status').selectpicker('refresh');
                }
                if (materType && materType === "QDMaterial") {
                      //设置产品类别为元宇宙
                    $('#pro_type').selectpicker('val', '6');
                }
            },
            initForm: function () {
                if (!fileId)
                    return false;
                else {
                    $('#orgFormTable').resetHideValidForm();
                    $.ajax({
                        type: 'post',
                        url: ctx + '/SourceManager/GetEntryData/' + fileId,
                        dataType: 'json',
                        async: false,
                        success: function (data) {
                            if (data.Statu === 0) {
                                var result = data.Data.info, folder = data.Data.folder;
                                $file_status = result.file_status;
                                if (result) {
                                    if (entryType && entryType === "approve") {
                                        //审核
                                        result["isRecommend"] = "0";//默认推荐
                                        result.file_status = "5";//默认审核通过
                                    } else {
                                        if (result.is_recommend)
                                            result["isRecommend"] = "1";
                                        else
                                            result["isRecommend"] = "0";
                                    }
                                    if (result.approve_time)
                                        result.approve_time = $.formatByDate(result.approve_time);
                                    if (result.update_time)
                                        result.update_time = $.formatByDate(result.update_time);
                                    if (result.create_time)
                                        result.create_time = $.formatByDate(result.create_time);
                                    if (result.allow_edit)
                                        result["allowEdit"] = "1";
                                    else
                                        result["allowEdit"] = "0";
                                    switch (result.file_status) {
                                        case 0:
                                        case 1:
                                        case 3:
                                        case 5: $('#fileStatus').removeAttr("disabled"); break;
                                        default: $('#fileStatus').attr("disabled", "disabled"); break;
                                    }
                                    if (result.file_status != 0)
                                        result["fileStatus"] = "1";
                                    else
                                        result["fileStatus"] = "0";
                                }
                                $('#orgFormTable')[0].reset();//重置表单
                                $('#orgFormTable').LoadForm(result);//表单填充数据
                                $('#folder_name').val(folder.folder_name);
                                $('#folder_id').val(folder.folder_id);
                                $('#folder_path').val(folder.folder_path);
                                //判断是否只读
                                if (isread) {
                                    //只读
                                    $('#orgFormTable').find("input,textarea").attr("disabled", true);
                                    $('#orgFormTable').find("select").next("div").children("button").attr("disabled", true);
                                }
                                $('button.disabled ').css("background-color", "#EEEEEE");
                            }
                            else
                                layer.msg(data.Msg, { icon: 5 });
                        }
                    });
                }
            },
            saveForm: function (indexForm) {
                if ($('#orgFormTable').valid()) {
                    var allow_edit = ($('#allowEdit').val() === "0") ? false : true, fileStatus = $('#fileStatus').attr("disabled");
                    var filePrice = $('.filePrice'), listPrice = [];
                    //元宇宙隐藏项目
                    if (materType && materType === "QDMaterial") {
                        listPrice.push({
                            op_month: $('#file_title').val(),
                            file_price: $('#file_price').val()
                        });
                    } else {
                        $.each(filePrice, function (index, item) {
                            listPrice.push({
                                op_month: $(item).attr("op_month"),
                                file_price: $(item).val()
                            });
                        });
                    }
                    var $data = {
                        allow_edit: allow_edit,
                        status: $('#fileStatus').val(),
                        file_status: $('#file_status').val(),
                        all_status: $file_status,
                        entryType: entryType,
                        saveType: 'other',
                        listPrice: listPrice,
                        sourceType: 'mater' //素材类别
                    };
                    //推荐
                    var isRecommend = $('#isRecommend').val();
                    if (isRecommend === "1")
                        $('#is_recommend').val(true);
                    else
                        $('#is_recommend').val(false);
                    if (fileStatus)
                        $data["fileStatus"] = $('#file_status').val();
                    //验证通过
                    if (!$('#file_code').val() && operator!="add") {
                        layer.alert("代码项唯一并且必填！");
                        return false;
                    }
                    //单位名称
                    $('#org_unit').val($('#unit_code').find("option:selected").text());//所属单位 名称
                    if (!fileId) {
                        //金额
                        //let priceList = $('.filePrice'), listPrice = [];
                        //$.each(priceList, function (index, item) {
                        //    if ($(item).val()) {
                        //        listPrice.push({
                        //            "file_price": $(item).val(),
                        //            "op_month": $(item).attr("op_month")
                        //        });
                        //    }
                        //});
                        let info = {}, obj = $('#orgFormTable').serializeArray();
                        $.each(obj, function (i, v) {
                            info[v.name] = v.value;
                        });
                        //添加
                        $.ajax({
                            url: ctx + "/SourceManager/AddVRManagerEntryData",
                            type: "post",
                            cache: false,
                            async: false,
                            data: { "listPrice": listPrice, "info": info, "page_type": pageType,"folder_id": folder_id, "folder_path": folder_path },
                            dataType: 'json',
                            success: function (result) {
                                if (result.Statu === 0) {
                                    layer.msg("添加成功！", { icon: 6 });
                                    fileId = result.Data;
                                    $('#file_id').val(result.Data);
                                    window.parent.docManager.closeIndexForm(indexForm);
                                    layer.closeAll();
                                    return true;
                                }
                                else {
                                    layer.alert(result.Msg, { icon: 5 });
                                    return false;
                                }
                            },
                            error: function () {
                                layer.msg('数据异常~', { icon: 5 });
                            }
                        });
                    } else {
                        //编辑
                        $('#orgFormTable').ajaxSubmit({
                            url: ctx + "/SourceManager/SaveEntryData",
                            type: "post",
                            data: $data,
                            dataType: "json",
                            beforeSubmit: function (arr, $form, options) {
                                layer.msg("提交数据~", { icon: 1, time: 5000 });
                            },
                            success: function (result, status, xhr, $form) {
                                if (result.Statu === 0) {
                                    layer.msg("更新成功！", { icon: 6 });
                                    window.parent.docManager.closeIndexForm(indexForm);
                                    return true;
                                }
                                else {
                                    layer.alert(result.Msg, { icon: 5 });
                                    return false;
                                }
                            },
                            error: function (xhr, status, error, $form) {
                                layer.msg("保存失败~", { icon: 5 });
                            }
                        });
                    }
                } else {
                    layer.msg("请检查必填项是否填写正确！", { icon: 5 });
                    return false;
                }
            },
            //绑定事件
            bindEvent:function(){
                $('#folder_name').on('click', function (event) {
                    if (!isFolder) {
                        //打开
                        $('#unitTree').slideDown();
                        isFolder = true;
                    } else {
                        //关闭
                        $('#unitTree').slideUp();
                        isFolder = false;
                    }
                    event.stopPropagation();
                });
                $('#entryHtml').on('click', function () {
                    //if (isFolder) {
                    //    $('#unitTree').slideUp();
                    //    isFolder = false;
                    //}
                });
            },
            //素材、作品树
            //2.2采用Ztree初始化文档树
            bindZtree: function () {
                var setting = {
                    view: {
                        showIcon: true,
                        selectedMulti: false,
                        fontCss: getFontCss
                    },
                    edit: {
                        enable: true,
                        showRemoveBtn: false,
                        showRenameBtn: false
                    },
                    async: {
                        enable: true,
                        dataType: "text",
                        type: "post",
                        url: ctx + "/DocManager/GetDocTreeData?pro_type=" + pro_type + "&doc_type=" + doc_type + "&isNum=1&pageType=" + pageType,
                        autoParam: ["id"]
                    },
                    data: {
                        key: { title: "name", name: "name" },
                        simpleData: { enable: true, idKey: "id", pIdKey: "pId", rootPId: 0 }
                    },
                    check: {
                        enable: false,
                        autoCheckTrigger: true,
                        chkStyle: "checkbox",
                        chkboxType: { "Y": "p", "N": "ps" }
                    },
                    callback: {
                        onAsyncError: function () {
                            layer.msg("初始化单位结构树失败~", { icon: 5 });
                        },
                        onAsyncSuccess: function (event, treeId, treeNode, msg) {
                        },
                        onClick: function (event, treeId, treeNode) {
                            $('#unitTree a').css("color", "#333");
                            $('#' + treeNode.tId + '_a').css("color", "#ffffff");
                            $('#folder_id').val(treeNode.id);
                            $('#folder_path').val(treeNode.folder_path);
                            $('#unitTree').slideUp();
                            var folderName = treeNode.name;
                            if (folderName.indexOf('(') > -1)
                                $('#folder_name').val(folderName.substring(0, folderName.indexOf('(')));
                            else
                                $('#folder_name').val(folderName);
                            isFolder = false;
                        }
                    }
                };
                unitzTree = $("#unitTree").initzTreeView(setting, 'ushow');
            }
        }
        $(function(){
            //初始化Page
            entryManager.initPage();
            //元宇宙隐藏项目
            if (materType && materType === "QDMaterial") {
                $('#QD_pro_type').css("display", "none");
                $('#QD_file_classify').css("display", "none");
                $('#QD_supplyType').css("display", "none");
                $('#QD_fileStatus').css("display", "none");
                $('#QD_unit_code').css("display", "none");
                $('#QD_file_status').css("display", "none");
                $('.bootstrap-select').css("width", "150px !important;");
                //价格
                if (priceTitle && priceMoney) {
                    $('#file_title').selectpicker('val', priceTitle);
                    $('#file_price').val(priceMoney);
                }
            }
        });
    </script>
}